package com.teach;

import java.io.File;
import java.io.IOException;
import java.net.URI;

public class FileTest {

	public static void main(String[] args) {
		File f1 = new File("a.txt");//相对路径
		System.out.println(f1);
		
		//完整路径,绝对路径
		File f2 = new File("D:\\upload\\a.txt");
//		f2 = new File("d:/upload/a.txt");
//		f2 = new File("d:/upload/a.txt");
		System.out.println(f2);
		System.out.println(File.pathSeparator);
		System.out.println(File.pathSeparatorChar);
		System.out.println(File.separator);
		System.out.println(File.separatorChar);
		
		//linux
//		File f3 = new File("/etc/sysconfig/network-scripts/ifcfg-ens18");
//		System.out.println(f3);
		
		//目录
		File f4 = new File("d:/upload");
		
		//获取文件的绝对路径
		System.out.println(f1.getAbsolutePath());
		System.out.println(f1.getAbsoluteFile());
		System.out.println(f2.getAbsolutePath());
		
//		f2 = new File(f4,"‪‪a.txt");

//		f2 = new File("d:/upload/a.txt");
		//是否存在
		System.out.println("f1.exists():"+f1.exists());
		System.out.println("f2.exists():"+f2.exists());
//		System.out.println("f3.exists():"+f3.exists());
		System.out.println("f4.exists():"+f4.exists());
		
		System.out.println("f1.isFile():"+f1.isFile());//是否是文件
		System.out.println("f1.isDirectory()"+f1.isDirectory());//是否是文件夹
		System.out.println("f2.isFile():"+f2.isFile());//是否是文件
		System.out.println("f2.isDirectory()"+f2.isDirectory());//是否是文件夹
		System.out.println("f4.isFile():"+f4.isFile());//是否是文件
		System.out.println("f4.isDirectory()"+f4.isDirectory());//是否是文件夹
	
		URI uri = f2.toURI();
		System.out.println(uri);
		
		
	}
}
